package org.example.chapter5.pojo;

import org.apache.ibatis.type.Alias;
import org.example.chapter5.enumeration.SexEnum;

import java.util.Objects;

/**
 * @author CoderXshuai
 * @date 2020/7/26/0026 22:28
 */
//MyBatis指定别名
@Alias(value = "user")
public class User {
    private Long id = null;
    private String userName = null;
    //性别枚举,需要使用typeHandler进行转换
    private SexEnum sex = null;
    private String note;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }


    public SexEnum getSex() {
        return sex;
    }

    public void setSex(SexEnum sex) {
        this.sex = sex;
    }


    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        User tUser = (User) o;
        return id.equals(tUser.id) &&
                sex == tUser.sex &&
                Objects.equals(userName, tUser.userName) &&
                Objects.equals(note, tUser.note);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, userName, sex, note);
    }
}
